package net.huashitong.ssydt.provider.web.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * 消息对象
 *
 * @author huiyang.yu
 */
@ApiModel(description = "返回结果对象")
public class Result<T extends Serializable> implements Serializable {

    private static final long serialVersionUID = 6950180245460613755L;

    @ApiModelProperty(value = "返回消息", dataType = "String")
    private String message;
    @ApiModelProperty(value = "返回值", dataType = "String")
    private String code = Status.SUCCESS;
    @ApiModelProperty(value = "返回的数据体")
    private T results;
    @ApiModelProperty(value = "时间戳")
    private Long timestamp = System.currentTimeMillis();

    public Result() {
    }

    public Result(String code) {
        this.code = code;
    }

    public Result(String code, String message) {
        this.message = message;
        this.code = code;
    }

    public Result(String code, String message, T results) {
        this.message = message;
        this.code = code;
        this.results = results;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getResults() {
        return results;
    }

    public void setResults(T results) {
        this.results = results;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public static final class Status {
        /**
         * 业务处理成功
         */
        public static final String SUCCESS = "200";

        // ==========url拦截的状态码==============
        /**
         * 参数错误
         */
        public static final String PARAM_ERROR = "40001";

        /**
         * 链接失效（超时）
         */
        public static final String OVERTIME = "40002";

        /**
         * 登录超时
         */
        public static final String LOGINOUT = "40003";

        /**
         * 别处登录
         */
        public static final String LOGIN_ELSEWHERE = "40004";
        /**
         * 请绑定手机
         */
        public static final String BIND_MOBILE = "40012";
        /**
         * 升级VIP
         */
        public static final String UPGRADE_VIP = "40013";

        /**
         * 错误
         */
        public static final String ERROR = "500";

        private Status() {
        }
    }

}
